#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

// 2294. 划分数组使最大差为 K
// https://leetcode.cn/problems/partition-array-such-that-maximum-difference-is-k/description/?envType=daily-question&envId=2025-06-19

class Solution1
{
public:
    int partitionArray(vector<int> &nums, int k)
    {
        set<int> numSet(nums.begin(), nums.end());
        int ans = 1;
        int left = 0;
        auto pre = *numSet.begin();
        for (auto &it : numSet)
        {
            if (pre == it)
            {
                continue;
            }
            if (it - pre > k)
            {
                pre = it;
                ans++;
            }
        }
        return ans;
    }
};

class Solution {
public:
    int partitionArray(vector<int>& nums, int k) {
        sort(nums.begin(), nums.end());
        int pre = 0;
        int ans = 1;
        for (int i = 0; i < nums.size(); i++)
        {
            if(pre == i){
                continue;
            }
            if(nums[i] - nums[pre] > k){
                pre = i;
                ans++;
            }
        }
        return ans;
    }
};

int main()
{
    return 0;
}